import { S } from '../../s';
import { IPSAppMethodDTO } from '../ipsapp-method-dto';
import { IPSApplication } from '../ipsapplication';
import { IPSAppDEMethodDTO } from './ipsapp-demethod-dto';
import { IPSAppDEMethodDTOField } from './ipsapp-demethod-dtofield';
import { IPSAppDataEntity } from './ipsapp-data-entity';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppDEMethodDTOImpl
  extends PSModelObjectImpl
  implements IPSAppDEMethodDTO
{
  get codeName(): string {
    return this.M.codeName;
  }

  protected psappdemethoddtofields: IPSAppDEMethodDTOField[];
  getPSAppDEMethodDTOFields(): IPSAppDEMethodDTOField[] | null {
    return (
      this.psappdemethoddtofields ||
      (this.psappdemethoddtofields = this.fillChildListModel(
        this.M.getPSAppDEMethodDTOFields,
        S._3cf,
      ) as IPSAppDEMethodDTOField[])
    );
  }

  findPSAppDEMethodDTOField(objKey: any): IPSAppDEMethodDTOField | null {
    return this.getPSModel5(
      S._3cf,
      this.getPSAppDEMethodDTOFields(),
      objKey,
    ) as IPSAppDEMethodDTOField;
  }

  protected refpsappdemethoddto: IPSAppDEMethodDTO;
  getRefPSAppDEMethodDTO(): IPSAppDEMethodDTO | null {
    if (this.refpsappdemethoddto != null) return this.refpsappdemethoddto;
    const value = this.M.getRefPSAppDEMethodDTO;
    if (value == null) {
      return;
    }
    this.refpsappdemethoddto =
      this.getRefPSAppDataEntity().findPSAppDEMethodDTO(value);
    return this.refpsappdemethoddto;
  }

  protected refpsappdataentity: IPSAppDataEntity;
  getRefPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.refpsappdataentity ||
      (this.refpsappdataentity = this.fillObjectModel(
        S._f,
        this.M.getRefPSAppDataEntity,
        S._3ce,
      ) as IPSAppDataEntity)
    );
  }

  get sourceType():
    | 'DE'
    | 'DYNAMODEL'
    | 'DEACTIONINPUT'
    | 'DEFILTER'
    | 'REFDE'
    | 'DEDATASETINPUT' {
    return this.M.sourceType;
  }

  protected srcpsappmethoddto: IPSAppMethodDTO;
  getSrcPSAppMethodDTO(): IPSAppMethodDTO | null {
    if (this.srcpsappmethoddto != null) return this.srcpsappmethoddto;
    const value = this.M.getSrcPSAppMethodDTO;
    if (value == null) {
      return;
    }
    const ipsapplication = this.getParentPSModelObject(
      S._26e,
    ) as IPSApplication;
    if (ipsapplication != null) {
      this.srcpsappmethoddto = ipsapplication.findPSAppMethodDTO(value);
    }
    return this.srcpsappmethoddto;
  }

  get type(): 'DEFAULT' | 'DEACTIONINPUT' | 'DEFILTER' | 'DEDATASETINPUT' {
    return this.M.type;
  }
  get cls(): string {
    return 'PSAppDEMethodDTOImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._3cc) return true;
    return super.instanceof(cls);
  }
}
